package cn.gson.crm.controller.apply;

import java.io.IOException;
import java.sql.Timestamp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.ApplyDao;
import cn.gson.crm.model.entity.Customer;

/**
 * Servlet implementation class ApplyUpdateServlet
 */
@WebServlet("/apply/update")
public class ApplyUpdateServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private ApplyDao ad = new ApplyDao();

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String status = request.getParameter("status");
		String applyId = request.getParameter("applyId");
		ad.updateApplyStatusByApplyIdAndStatusId(Integer.parseInt(applyId), Integer.parseInt(status));
		if("2".equals(status)){
			redirect("apply/form");
			return;
		}else{
			redirect("manager");
			return;
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
